<?php
namespace App\HttpController\Admin;

use App\Common\Controller\Rest;

class Users extends Rest
{
    public $modelName = 'User';

    /**
     * 修改密码
     */
    public function POSTModifypass()
    {
        $param = $this->param;
        $old_pwd = $param['old_pwd'];
        $new_pwd = $param['new_pwd'];
        $password = $this->model()->where('id', $param['adminId'])->value('password');
        $this->abort(user_md5($old_pwd) == $password, ['msg' => '原密码错误']);
        $this->abort(user_md5($new_pwd) != $password, ['msg' => '密码没改变']);
        $this->result($this->model()->where('id', $param['adminId'])->setField('password', user_md5($new_pwd)));
    }
}
